<template>
  <div class="index-banner-container">
    <swiper class="banner"
            :options="bannerSwiperOption">
      <swiper-slide v-for="item in banners"
                    :key="'ad_'+item.adv_id"
                    class="banner-item">
        <a :href="item.adv_link"
           style="display:block;">
          <img class="banner-img"
               :src="item.adv_code">
        </a>
      </swiper-slide>
    </swiper>
    <div class="banner-pagination"></div>
  </div>
</template>

<script>
export default {
  name: 'Banner',
  data() {
    return {
      bannerSwiperOption: Object.freeze({
        // 轮播图配置
        pagination: {
          el: '.banner-pagination'
        },
        autoplay: true,
        loop: true
      })
    }
  },
  props: {
    banners: {
      type: Array,
      default: () => []
    }
  }
}
</script>

<style lang="scss">
// 轮播图
.index-banner-container {
  width: 100%;
  padding: 0 10px 10px 10px;
  border-radius: 10px;
  position: relative;
  .banner {
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    .banner-item {
      width: 100%;
      img {
        width: 100%;
        height: 170px;
      }
    }
  }
  .banner-pagination {
    position: absolute;
    bottom: 15px;
    left: 0;
    width: 100%;
    z-index: 100;
    text-align: center;
    /deep/ .swiper-pagination-bullet {
      margin-right: 5px;
      background-color: #ffffff;
      opacity: 0.6;
    }
    /deep/ .swiper-pagination-bullet-active {
      width: 15px;
      height: 8px;
      border-radius: 4px;
      background-color: #ffffff;
      opacity: 1;
    }
  }
}
</style>
